<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.netcombine.freewill.constants.*, com.netcombine.freewill.vo.FreewillVo, com.netcombine.freewill.lib.Paging,com.netcombine.freewill.vo.PagingVo" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
Paging paging = (Paging)request.getAttribute("paging");

PagingVo vo = (PagingVo)request.getAttribute("pagingVo"); 


int total_cnt = paging.getTotalCnt();

String searchName = "";
String searchWord = "";
String mb_idx = "";

if(vo != null){
	searchName = vo.getSearchName() == null ? "" : vo.getSearchName();
	searchWord = vo.getSearchWord() == null ? "" : vo.getSearchWord();
}
%>
<html>
<head>

<title><%=PageInfo.TITLE%> - 회원</title>
<tiles:insertDefinition name="_head" />
<link rel="stylesheet"
	href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript"
	src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
  $(function() {
	$( "#startday" ).datepicker({
	  showOn: "button",
	  buttonImage: "<%= PageInfo.IMG_PATH %>/icon_calendar.png",
	  buttonImageOnly: true,
	  dateFormat:"yy-mm-dd",
	  defaultDate: "+1w",
	  changeMonth: true,
	  numberOfMonths: 1,
	  onClose: function( selectedDate ) {
		$( "#lastday" ).datepicker( "option", "minDate", selectedDate );
	  }
	});
	$( "#lastday" ).datepicker({
	  showOn: "button",
	  buttonImage: "<%= PageInfo.IMG_PATH %>/icon_calendar.png",
	  buttonImageOnly: true,
	  dateFormat:"yy-mm-dd",
	  defaultDate: "+1w",
	  changeMonth: true,
	  numberOfMonths: 1,
	  onClose: function( selectedDate ) {
		$( "#startday" ).datepicker( "option", "maxDate", selectedDate );
	  }
	});
  });
 function searchFrm(){
	  var frm = document.searchForm;
	  
	  frm.action = "<%= request.getContextPath() %>/user/list.do";
	  frm.submit();
	  
  }
 function userview(mb_idx){
	 var frm = document.writeFrm;
	 frm.mb_idx.value = mb_idx;
	 
	 frm.action = "<%= request.getContextPath() %>/user/userview.do";
	 
	 frm.submit();
 }
</script>

</head>

<body>
	<div class="wrap">
		<tiles:insertDefinition name="_header" />

<!-- Container -->
<div class="container">
	<div>
		<tiles:insertDefinition name="_menu" />
	<!-- Content -->
	<div class="content">

		<!-- locatioin -->
		<div class="location">
			<h1>회원관리</h1>
			<ul>
				<li class="home"><a href="#none"><span>home</span></a> &gt;</li>
				<li><a href="#none">회원관리</a> &gt;</li>
				<li><strong>회원 관리</strong></li>
			</ul>
		</div>
		<!-- locatioin // -->
<form name="searchForm" method="POST">
		<!-- member_search -->
		<div class="member_search">
			<table summary="회원관리, 검색설정, 검색기간">
				<caption>회원관리</caption>
				<colgroup>
					<col style="width: 15%">
					<col style="width: *;">
					<col style="width: 15%">
				</colgroup>
				<tbody>
					<tr>
						<th>가입일</th>
						<td>
							 <input type="text" id="startday" name="startday" title="검색 시작날짜"
							class="i_text inw8" /> ~ <input type="text" id="lastday" name="lastday"
							title="검색 마지막날짜" class="i_text inw8" />
						</td>
						<td rowspan="2" class="txtC"><span
							class="btn_member bgnone"><a href="javascript: searchFrm();">검색</a></span></td>
					</tr>
					<tr>
						<th><select name="searchName">
								<option value="이름" <%if(searchName.equals("이름")){ out.print("selected='selected'");} %>>이름</option>
								<option value="핸드폰" <%if(searchName.equals("핸드폰")){ out.print("selected='selected'");} %>>핸드폰</option>
								<option value="주소" <%if(searchName.equals("주소")){ out.print("selected='selected'");} %>>주소</option>
						</select></th>
						<td><input type="text" name="searchWord" title="검색" class="i_text inw3" value="<%=searchWord%>"></td>
					</tr>
				</tbody>
			</table>		
	</div>
	</form>
		<form name="writeFrm" method="POST">
		<input type="hidden" name="mb_idx">
		<!-- member_search // -->

		<!-- search detail -->
		<div class="search_detail">
			<p class="txt">
				총 <span><%= total_cnt %></span> 명
			</p>
			<p class="right btn_excel">
				<a href="#none">EXCEL 저장</a>
			</p>
		</div>
		<!-- search detail // -->

		<!-- table -->
		<div class="tb_list1 tb_member1">
			<table summary="번호, 이름, 생일, 핸드폰, 주소, 가입일, 가입커뮤니티, 공유, 요청, 찜">
				<caption>집합교육</caption>
				<colgroup>
					<col style="width: 8%;">
					<col style="width: 10%;">
					<col style="width: 6%;">
					<col style="width: 13%;">
					<col style="width: *;">
					<col style="width: 10%;">
					<col style="width: 8%">
					<col style="width: 6%;">
					<col style="width: 6%;">
					<col style="width: 6%">
				</colgroup>
				<thead>
					<tr>
						<th scope="col"><div>No.</div></th>
						<th scope="col"><div>이름</div></th>
						<th scope="col"><div>생일</div></th>
						<th scope="col"><div>핸드폰</div></th>
						<th scope="col"><div>주소</div></th>
						<th scope="col"><div>가입일</div></th>
						<th scope="col"><div>가입<br>커뮤니티</div></th>
						<th scope="col"><div>공유</div></th>
						<th scope="col"><div>요청</div></th>
						<th scope="col"><div>찜</div></th>
					</tr>
				</thead>
				<tbody>
				<%
					if (total_cnt != 0) {
				%>
				<c:forEach items="${userList}" var="vo" >
					<tr onclick="javascript: userview('${vo.mb_idx}');">
						<td><%=total_cnt--%></td>
						<td><c:out value="${vo.mb_name}" /> </td>
						<td><c:out value="${vo.mb_birth}" /></td>
						<td><c:out value="${vo.mb_ph1} ${vo.mb_ph2} ${vo.mb_ph3}" /></td>
						<td><c:out value="${vo.addr_sido} ${vo.addr_sigungu} ${vo.mb_addrdetail}" /></td>
						<td><c:out value="${vo.mb_regdate}" /></td>
						<td><c:out value="${vo.cmjoin_cnt}" /></td>
						<td><c:out value="${vo.share_cnt}" /></td>
						<td><c:out value="${vo.request_cnt}" /></td>
						<td><c:out value="${vo.fork_cnt}" /></td>
						
					</tr>
				</c:forEach>
				<%
					} else {
				%>
					<tr>
						<td colspan="10">등록된 회원이 없습니다.</td>
					</tr>
				<% } %>

				</tbody>
			</table>
		</div>
		</form>
		
		${paging.getPagingHtml()}
	</div>
</div>

		</div>
	</div>

<form name="pageForm" method="POST">
<input type="hidden" name="page" value="${pagingVo.page}"/>
<input type="hidden" name="searchName" value="${pagingVo.searchName}"/> 
<input type="hidden" name="searchWord" value="${pagingVo.searchWord}" />
</form>

</body>
</html>